package 类和对象课堂练习;

public class Lianxi03212 {
    String name;
    String tecaher;
    String date;
    String[] stus = new String[30];

    public void add(String xuename) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                stus[i] = xuename;
                break;
            }
        }

    }

    public void showInformation() {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] != null) {
                System.out.println(stus[i] + "");
            } else {
                break;
            }
        }
    }

    public boolean searchName(String name) {
        for (int i = 0; i < stus.length; i++) {
            if (name.equals(stus[i])) {
                return true;
            }
        }
        return false;
    }
    public boolean abb(String name1,String name2){
        for (int i = 0; i < stus.length; i++) {
            if (name1.equals(stus[i])){
                stus[i]=name2;
            }
            if (name2.equals(stus[i])){
               return true;
            }
       }
        return false;
    }
    public int renshu(){
        int b=0;
        for (int i = 0; i < stus.length;i++ ) {
            if (stus[i]!=null){
                b++;
            }
        }
        return b;

    }
}
